﻿using System;
using System.Collections.Generic;
using System.Text;
using AMS.DataAccess.Properties;

namespace AMS.DataAccess.Sql
{
    /// <summary>
    /// 枚举类型作为表达式右边的条件表达式
    /// </summary>
    /// <typeparam name="T">必需是枚举类型</typeparam>
    public class SqlEnumCondition<T> : SqlCondition
    {
        /// <summary>
        /// 枚举类型作为表达式右边的条件表达式
        /// </summary>
        /// <param name="expr">表达式</param>
        /// <param name="value">枚举值</param>
        public SqlEnumCondition(string expr, T value)
            : base(expr, Convert.ToInt32(value))
        {
            if (!typeof(T).IsSubclassOf(typeof(Enum)))
            {
                throw new ArgumentException(Resources.EnumTypeRequired);
            }
        }
    }
}
